package com.cvic.se.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cvic.se.entity.Department;
import com.cvic.se.mapper.DepartmentMapper;
import com.cvic.se.service.DepartmentService;
import com.cvic.se.utils.Result;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * InnoDB free: 4096 kB; (`INST_ID`) REFER `work1/institution`(`INST_ID`) 服务实现类
 * </p>
 *
 * @author zgx
 * @since 2021-07-21
 */
@Service
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService {

	@Autowired
	DepartmentMapper departmentMapper;
	
	@Override
	public Result getAllDept(String instId){
		
		List<Department> list = departmentMapper.getAll(instId);
		
		if(!list.isEmpty()) {
			return Result.success().data("content", list);
		}
		return Result.error();
	}
	
	
	@Override
	public Result insertDept(Department dept) {
		int temp = departmentMapper.insertDept(dept);
		if(temp != 0) {
			return Result.success();
		}
		return Result.error();
	}
	
	@Override
	public Result deleteDept(Integer id) {
		int temp = departmentMapper.deleteDept(id);
		if(temp != 0) {
			return Result.success();
		}
		return Result.error();
	}
	
	@Override
	public Result updateDept(Department dept) {
		int temp = departmentMapper.updateDept(dept);
		if(temp != 0) {
			return Result.success();
		}
		
		return Result.error();
	}
	
}
